package com.lj.common.utils.qywx.builder;

import cn.hutool.core.util.StrUtil;
import com.lj.common.exception.CommonException;

import java.nio.charset.StandardCharsets;
import java.util.List;

/**
 * @author luojing
 * @date 2025/3/22
 */
public class MarkdownBuilder extends AbstractMsgBuilder {


    private MarkdownBuilder() {
    }

    /**
     * @param content markdown内容，最长不超过4096个字节，必须是utf8编码
     */
    public static MarkdownBuilder builder(String content) {
        if (StrUtil.isBlank(content)) {
            throw new CommonException("markdown类型消息 content参数不能为空");
        }
        byte[] bytes = content.getBytes(StandardCharsets.UTF_8);
        if (bytes.length > 4096) {
            throw new CommonException("markdown类型消息 content最长不超过4096个字节");
        }
        MarkdownBuilder markdownBuilder = new MarkdownBuilder();
        markdownBuilder.builder.put("content", content);
        return markdownBuilder;
    }
}
